<template>
	<view class="content" v-show="show">
		<!-- 头部导航 -->
		<view class="w-750 w-bj-cont" style="position: fixed; top: 0; left: 0;">
			<view class="h-100 w-row-justify-between-align">
				<view class="wh-80 w-row-center" @click="routerBack()">
					<image class="wh-40" src="../../../static/gane/fh.png"></image>
				</view>
				<view class="w-250 h-100 w-row-center w-wz-conts font-36">
					<text v-if="type == 'all_amoney'">总佣金</text>
					<text v-else>今日佣金</text>
				</view>
				<view class="wh-80 w-row-center">
					<uni-datetime-picker v-if="type == 'all_amoney'" type="datetimerange" @change="changeTiem">
						<image class="wh-50" src="../../../static/gane/rq.png"></image>
					</uni-datetime-picker>
				</view>
			</view>
		</view>
		<view class="bwh-120"></view>
		<!-- 头部导航结束 -->
        <view class="w-720 h-200 w-column-align m-top-50" v-if="tableData.length == 0">
        	<image class="wh-150" src="../../../static/gane/zwsj.png"></image>
        	<text class="w-wz-conts">暂 无 数 据 </text>
        </view>
		<!-- 内容区域 -->
		<view class="w-720 w-bj-cont w-bor-12 w-column-align m-bottom-20 font-24 w-wz-conts"
			v-for="(item,index) in tableData">
			<view class="h-10"></view>
			<!-- <view class="w-680 p-2 w-row-justify-between-align">
				<text class="font-26 w-wz-cont"># {{index+1}}</text><text class="w-wz-black8"></text>
			</view> -->
			<view class="w-680 p-2 w-row-justify-between-align">
				<text class="font-26">订单单号</text><text class="w-wz-black8">{{item.order_id}}</text>
			</view>
			<!-- <view class="w-650 p-2 w-row-justify-between-align">
				<text class="font-26">订单渠道</text><text>{{item.game_name}}</text>
			</view> -->
			<view class="w-680 p-2 w-row-justify-between-align">
				<text class="font-26">订单金额</text><text class="w-wz-gree">{{item.order_money}}</text>
			</view>
			<!-- <view class="w-680 p-2 w-row-justify-between-align">
				<text class="font-26">佣金费率</text><text class="w-wz-black8">{{item.agent_rate}}</text>
			</view> -->
			<view class="w-680 p-2 w-row-justify-between-align">
				<text class="font-26">订单佣金</text><text class="w-wz-red">{{item.agent_money}}</text>
			</view>
			<view class="w-680 p-2 w-row-justify-between-align">
				<text class="font-26">用户昵称</text><text class="w-wz-black8">{{item.user_name}}</text>
			</view>
			<view class="w-680 p-2 w-row-justify-between-align">
				<text class="font-26">订单时间</text><text class="w-wz-black8">{{item.create_time}}</text>
			</view>
			<view class="h-10"></view>
		</view>

		<view class="w-300 h-80  w-row-center w-bor-12">
			<text class="w-wz-conts font-28" v-if="isShow">没有数据了...</text>
		</view>

		<view class="wh-30"></view>
	</view>

</template>

<script>
	import $H from '@/pages/common/request.js'
	export default {
		data() {
			return {
				tableData: [],
				show: false,
				start_time: '',
				end_time: '',
				pagenum: 1,
				type: '',
				total: null,
				isShow: false
			}
		},

		onLoad(e) {
			let type = e.type
			if (typeof type == 'undefined') {
				return uni.reLaunch({
					url: '/pages/index/index'
				});
			}
			this.type = type
			this.getUserAgentLog()
		},

		onReachBottom() {

			uni.showLoading({
				title: '加载数据中...'
			});
			
			if (this.tableData.length == this.total) {
				this.isShow = true
			} else {
				this.pagenum++
				this.getUserAgentLog()
			}
			let timer = setInterval(() => {
				uni.hideLoading();
			clearTimeout(timer)
			}, 600);
			console.log('到底了')

		},

		methods: {

			changeTiem(val) {
				this.start_time = val[0]
				this.end_time = val[1]
				this.tableData = []
				this.getUserAgentLog(true)
			},

			getUserAgentLog(isBool) {
				$H.post('/app_user_agent_log', {
					type: this.type,
					pagenum: this.pagenum,
					start_time: this.start_time,
					end_time: this.end_time,
				}).then((res) => {

					if (res.code == 200) {
						if(isBool){
							if(res.data.data.length == 0){
								this.tableData = []
								this.isShow =true
							}else{
								this.tableData.push(...res.data.data)
							}
						}else{
							this.tableData.push(...res.data.data)
							this.total = res.data.total
							this.show = true
						}
										
					} else {
						return uni.showToast({
							title: res.msg,
							duration: 1000,
							icon: 'none'
						});
					}
				})
			},

			


		}
	}
</script>

<style>

</style>
